<?php

use yii\helpers\Html;
use yii\bootstrap\ActiveForm;
use kartik\select2\Select2;
use app\models\Supplier;

$supplier = Supplier::find()->where(['status'=>1])->asArray()->all();
$supplier = yii\helpers\ArrayHelper::map($supplier,'id','company');
$city = Yii::$app->params['city'];
?>

<div class="cruise-form">
    <?php $form = ActiveForm::begin([
                                     'options' => ['enctype' => 'multipart/form-data',],
                                     'layout' => 'horizontal',
                                     'fieldConfig' => [
                                        'template' => "{label}\n{beginWrapper}\n{input}\n{hint}\n{error}\n{endWrapper}",
                                        'horizontalCssClasses' => [
                                            'label' => 'col-sm-2',
                                            'wrapper' => 'col-sm-7',
                                            'error' => '',
                                        ],
                                     ],
                                ]); ?>

    <?php echo $form->field($model, 'supplier_id')->widget(Select2::classname(), [
                'data' =>$supplier,
                'language' => 'zh-cn',
                'options' => ['placeholder' => '选择供应商....'],
                'pluginOptions' => [
                    'allowClear' => true
                ],
            ]) ?>

    <?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'en_name')->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'code',['template'=>'{label}<div class="col-md-3">{input}{error}</div>'])->textInput(['maxlength' => true]) ?>

    <?= $form->field($model, 'from_city',['template'=>'{label}<div class="col-md-3">{input}{error}</div>'])->widget(Select2::classname(), [
                'data' =>$city,
                'language' => 'zh-cn',
                'options' => ['placeholder' => '选择出发城市....'],
                'pluginOptions' => [
                    'allowClear' => true,
                ],
            ]) ?>

    <?= $form->field($model, 'to_city',['template'=>'{label}<div class="col-md-3">{input}{error}</div>'])->widget(Select2::classname(), [
                'data' =>$city,
                'language' => 'zh-cn',
                'options' => ['placeholder' => '选择返港城市....'],
                'pluginOptions' => [
                    'allowClear' => true,
                ],
            ]) ?>



    <?= $form->field($model, 'weight',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('吨')->textInput() ?>
    <?= $form->field($model, 'num',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('人')->textInput() ?>

    <?= $form->field($model, 'length',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('米')->textInput() ?>

    <?= $form->field($model, 'width',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('米')->textInput() ?>

    <?= $form->field($model, 'room',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('间')->textInput() ?>

    <?= $form->field($model, 'ceil',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('层')->textInput() ?>

    <?= $form->field($model, 'speed',['template'=>'{label}<div class="col-md-3">{input}{error}</div>{hint}'])->hint('节')->textInput() ?>

    <?= $form->field($model, 'first',['template'=>'{label}<div class="col-sm-4">{input}{hint}</div>{error}'])
                                        ->widget(kartik\date\DatePicker::classname(),[
                                                    'options' => ['placeholder' => '开业时间'],
                                                    'pluginOptions' => [
                                                        'format' => 'yyyy',
                                                        'minViewMode' => 2,
                                                        'startView' => 'decade',
                                                        'autoclose'=>true,
                                                        'todayHighlight' => true
                                                    ]
                                                ]); ?>

    <?= $form->field($model, 'renovation',['template'=>'{label}<div class="col-sm-4">{input}{hint}</div>{error}'])
                                        ->widget(kartik\date\DatePicker::classname(),[
                                                    'options' => ['placeholder' => '翻新时间'],
                                                    'pluginOptions' => [
                                                        'format' => 'yyyy',
                                                        'minViewMode' => 2,
                                                        'startView' => 'decade',
                                                        'autoclose'=>true,
                                                        'todayHighlight' => true
                                                    ]
                                                ]); ?>

    <?= $form->field($model, 'desc')->textArea(['maxlength' => true]) ?>

    <?= $form->field($model, 'status')->inline(true)->radioList(\Yii::$app->params['status']) ?>

    <!-- ?= $form->field($model, 'user_id')->textInput() ?>
    </?= $form->field($model, 'created_at')->textInput() ?>
    </?= $form->field($model, 'updated_at')->textInput() ? -->
    <?php // echo $this->render('../_image', ['model' => $model, 'type'=>1]); ?>
    <hr>
    <div class="form-group text-center">
        <?= Html::submitButton($model->isNewRecord ? Yii::t('app', 'Create') : Yii::t('app', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
    </div>

    <?php ActiveForm::end(); ?>

</div>
